package com.ruoyi.project.digital.util;

import com.ruoyi.common.constant.Constants;

import java.util.regex.Pattern;

public class CheckStrUtil {

    /**
     * 数字判断
     * @param str
     * @return
     */
    public static boolean isNumber(String str){
        Pattern pattern = Pattern.compile(".*\\d.*");
        return pattern.matcher(str).matches();
    }

    /**
     * 大写判断
     * @param str
     * @return
     */
    public static boolean isUpper(String str){
        Pattern pattern = Pattern.compile(".*[A-Z].*");
        return pattern.matcher(str).matches();
    }

    /**
     * 小写判断
     * @param str
     * @return
     */
    public static boolean isSmall(String str){
        Pattern pattern = Pattern.compile(".*[a-z].*");
        return pattern.matcher(str).matches();
    }

    /**
     *  特殊字符判断
     * @param str
     * @return
     */
    public static boolean isSpcStr(String str) {
        Pattern pattern = Pattern.compile(".*\\W.*");
        return pattern.matcher(str).matches();

    }

    /**
     * 检查会员项目的密码合法性
     * @param str
     * @return
     */
    public static   boolean checkPassWord(String str){
        if(isNumber(str)&&isSmall(str)&&isUpper(str)){
            return  true;
        }
        if(Constants.PASS_LENTH<str.length()){
            return  false;
        }
        return false;
    }

    public static void main(String[] args) {
        String reg="Fn123456";
        System.out.println(isNumber(reg));
        System.out.println(isSmall(reg));
        System.out.println(isUpper(reg));
    }
}
